const obj = {
  a: 1,
  b: {
    c: 2
  }
}

function clone(obj, result = {}) {
  for (let x in obj) {
    if (typeof obj[x] !== 'object') {
      result[x] =obj[x]
    } else {
      result[x] = {}
      clone(obj[x], result[x])
    }
  }
  return result
}

let newo = clone(obj)
console.log(newo)